<template>
	<view>
		<view class="fllow_form">
			<view style="width: 50%;">订单时间:</view>
			<!-- #ifdef MP-WEIXIN || H5 || APP-PLUS-->
			<picker style="width: 50%;" @change="changeTime" mode="multiSelector" :range="dateTimeArray"
				:value="dateTime">
				<view class="form_right">
					<view :class="orderDate ? 'valueActive' : '' ">{{orderDate ? orderDate : '点击选择'}}</view>
					<view class="iconfont icon-arrows_right"></view>
				</view>
			</picker>
			<!-- #endif -->
			<!-- #ifdef MP-ALIPAY -->
			<picker @change="changeAlipayTime" mode="date">
				<view class="form_right">
					<view :class="orderDate ? 'valueActive' : '' ">{{orderDate ? orderDate : '点击选择'}}</view>
					<view class="iconfont icon-arrows_right"></view>
				</view>
			</picker>
			<!-- #endif -->
		</view>
		<view class="fllow_form">
			<view style="width: 50%;">应付:</view>
			<view class="text">￥<input type="digit" v-model="mustPay" placeholder-style="font-size:30rpx;color: #999;"
					style="border-width:1rpx ; border-color:#d2cfcf;border-style: none none solid none;width: 60px;display: inline-flex;">
				<u-icon class="u-icon" name="edit-pen" size="20"></u-icon>
			</view>
		</view>
		<view class="fllow_form">
			<view style="width: 50%;">实付:</view>
			<view class="text">￥{{realPay}}元
			</view>
		</view>
		<view class="fllow_form">
			<view style="width: 50%;">欠费:</view>
			<view class="text">￥{{remainPay}}元
			</view>
		</view>
		<view class="fllow_form">
			<view>选择付款方式
			</view>
		</view>
		<view class="block">
			<view class="content">
				<view class="pay-list">

					<view class="fllow_form row" v-for="paytype in paytypes" v-if="ifShowPaytype(paytype.id)"
						@tap="payChecked=paytype.key">
						<view class="left">
							<image v-if="paytype.icon" :src="paytype.icon"></image>
							<u-icon v-else class="u-icon" name="rmb-circle"   color="#f06c7a" size="80"></u-icon>
						</view>
						<view class="center">
							{{paytype.title}}
						</view>
						<view class="center" v-if="payChecked==paytype.key">
							￥<input type="digit" v-model="payways[0].payamount"
								placeholder-style="font-size:30rpx;color: #999;"
								style="border-width:1rpx ; border-color:#d2cfcf;border-style: none none solid none;width: 60px;display: inline-flex;">
							<u-icon class="u-icon" name="edit-pen" size="20"></u-icon>
						</view>
						<view class="right">
							<radio :checked="payChecked==paytype.key" color="#f06c7a" />
						</view>
					</view>

					<view class="fllow_form row" v-for="paytype in custompaytypes" 	@tap="payChecked=paytype.key">
						<view class="left">
							<image v-if="paytype.icon" :src="paytype.icon"></image>
							<u-icon v-else class="u-icon" name="rmb-circle"   color="#f06c7a" size="80"></u-icon>
						</view>
						<view class="center">
							{{paytype.title}}
						</view>
						<view class="center" v-if="payChecked==paytype.key">
							￥<input type="digit" v-model="payways[0].payamount"
								placeholder-style="font-size:30rpx;color: #999;"
								style="border-width:1rpx ; border-color:#d2cfcf;border-style: none none solid none;width: 60px;display: inline-flex;">
							<u-icon class="u-icon" name="edit-pen" size="20"></u-icon>
						</view>
						<view class="right">
							<radio :checked="payChecked==paytype.key" color="#f06c7a" />
						</view>
					</view>
					<view class="fllow_form row"  v-if="orderType != 3 && memberInfo.integral > 0">
						<view class="left" style="width: 100px;">
							积分抵扣: 
						</view>
						<view class="center">
							￥<input type="digit" v-model="payPoints"
								placeholder-style="font-size:30rpx;color: #999;"
								style="border-width:1rpx ; border-color:#d2cfcf;border-style: none none solid none;width: 60px;display: inline-flex;">
							分抵{{payPointsAmount}}元
						</view> 
						<view class="right">
							余{{memberInfo.integral}}
						</view>
					</view>
				</view>
				<view class="fllow_area">
					<view class="area_head">订单备注</view>
					<textarea v-model="orderRemark" placeholder="请输入订单备注" placeholder-style="color:#999" />
				</view>
				<view class="fllow_form">
					<view>发送短信/微信</view>
					<view class="form_right">
						<radio-group @change="changeAuto" class="labellist">
							<label class="" class="labelbox">
								<view>
									<radio color="#ff7800" :checked="isSendsms == 1" value="1" />
								</view>
								<view>是</view>
							</label>
							<label class="" class="labelbox" style="margin-left: 10px;">
								<view>
									<radio color="#ff7800" :checked="isSendsms == 0" value="0" />
								</view>
								<view>否</view>
							</label>
						</radio-group>
					</view>
				</view>
			</view>
		</view>
		<view class="pay" style="margin-bottom: 50upx;">
			<view class="btn" @tap="$noMultipleClicks(saveOrder)">保存订单</view>
		</view>
	</view>
</template>

<script>
	import {
		getAppCtx
	} from '@/api/login.js'
	import {
		netSendConsumeMsg
	} from '@/api/index.js'
	import {
		netSaveOrder,
		OrderBean,
		getMemberDiscountBean,
		goodsClassTreeList,
		goodsList,
		netGetMembercard,
		payOptions
	} from '@/api/main.js'
	import {
		netAddkehu,
		netSelect,
		netKehuDetail
	} from '@/api/kehu.js'
	import {
		BASE_URL,
		BASE_IMG_URL
	} from '@/util/api'
	import {
		getNowData
	} from '@/util/weekTime.js'
	import {
		dateFormat
	} from '@/util/util.js'
	import {
		dateTimePicker,
		getMonthDay
	} from '@/util/dateTimePicker.js'
	export default {
		data() {
			return {
				BASE_IMG_URL: BASE_IMG_URL,
				noClick: true,
				dateTime: null,
				dateTimeArray: null,
				dateArr: null,
				amount: 0,
				isSendsms: 0,
				paytypeSettings: {

					"cash_enable": 1,
					"balance_enable": 1,
					"alipay_enable": 1,
					"wx_enable": 1,
					"mt_enable": 0,
					"scan_code_enable": 0,
					"give_enable": 1,
					"other_enable": 0,

				},

				payChecked: '',
				payCheckedArr: [],
				payways: [],
				custompaytypes: [],
				paytypes: payOptions,
				payOrder: false,
				orderDate: '',
				orderRemark: '',
				additional_no: '',
				cashierman: '',
				cashierman_name: '',
				isMulti: false,
				mustPay: 0,
				payPoints: 0,
				integration_convert: 0.01,
				discountsAmount: 0,
				payway2: null,
				scanModalIdx: '',
				memberInfo: {
					recharge: '0',
					give: '0',
					integral: '0'
				},
				coupon: {
					coupon_name: "",
					coupon_amount: 0,
				},

				cashierStaffs: [],
				projectCarts: [],
				productCarts: [],
			};
		},
		onUnload(e) {
			this.clearAll()
		},
		onLoad(e) {

			let that = this
			that.orderInfo = uni.getStorageSync('orderInfo')
			this.appCtx = getAppCtx()
			console.log("==========")
			if (that.appCtx.storeParameter) {
				that.integration_convert = that.appCtx.storeParameter.integration_convert;
				if (that.appCtx.storeParameter.is_cashier_sendsms) {
					that.isSendsms = that.appCtx.storeParameter.is_cashier_sendsms;
				}
				if (that.appCtx.storeParameter.paytype_settings) {
					that.paytypeSettings = Object.assign({}, that.paytypeSettings, JSON.parse(that.appCtx.storeParameter
						.paytype_settings))
					if (that.paytypeSettings.custom_paytype) {
						that.custompaytypes = (that.paytypeSettings.custom_paytype)
					}
				}
			}
	
			if(that.orderType == 1 && that.paytypeSettings.balance_enable && that.ifHasCharge ) {
				that.payChecked = '3';
			} else if(that.orderType == 1 && that.paytypeSettings.give_enable && that.ifHasGive) {
				that.payChecked = '13';
			} else {
				that.payChecked = that.defaultPaytype;
			}
	

			this.amount = parseFloat(e.amount).toFixed(2);

			this.initTime()


			that.init()

		},
		watch: {

			payPoints: {
				handler(newv, oldv) {
					var that = this;
					if (parseFloat(newv) > parseFloat(that.memberInfo.integral)) {
						alert("积分余额不足！");
						that.payPoints = oldv;
					} else {
						if (that.payway1) {
							that.payway1.payamount = (that.mustPay - parseFloat(that.payPointsAmount));
						}
					}

				}
			},
			payChecked: {
				handler(newv, oldv) {
					var that = this;
					console.log(newv)
					let ways = []
					let payChecked = newv
					let amount = that.mustPay
					if (that.payway1 && that.payway1.payamount > 0) {
						amount = that.payway1.payamount
					}
					ways.push({
						paytype: payChecked,
						title: payChecked >= 100 ? that.getCustomTitle(payChecked) + "支付" :
							/* DataDict["PAY_CODE"][payChecked] + */
							"支付",
						payamount: amount
					});


					that.payways = ways;


				},
				deep: true
			},
			payCheckedArr: {
				handler(newv, oldv) {
					var that = this;
					let ways = []
					if (this.isMulti) {
						newv.forEach((v, i) => {
							let payChecked = v;
							ways.push({
								paytype: payChecked,
								title: payChecked >= 100 ? that.getCustomTitle(payChecked) + "支付" :
									/* DataDict["PAY_CODE"][payChecked] + */
									"支付",
								payamount: (i == 0 ? that.mustPay : 0)
							});
						})
					}
					that.payways = ways;
				},
				deep: true
			},
			discountsAmount: {
				handler(newv, oldv) {
					var that = this;
					if (that.payway1) {
						that.payway1.payamount = (that.mustPay - parseFloat(that.discountsAmount));
					}
				},
				deep: true
			},
			coupon: {
				handler(newv, oldv) {
					var that = this;
					var disAfterPrice = (that.mustPay - (that.disAll));
					if (disAfterPrice >= 0) {
						that.payway1.payamount = disAfterPrice;
					} else {
						that.payway1.payamount = 0;
					}
				},
				deep: true
			},
			orderInfo: {
				handler(newv, oldv) {
					var _this = this;
				},
				deep: true
			},

		},
		computed: {
			payway1: function() { //第一个支付方式
				return this.payways[0]
			},
			orderType: function() { //是否开卡时原卡有充值卡可以划新卡  
				return this.orderInfo.orderType
			},
			defaultPaytype: function() { //是否开卡时原卡有充值卡可以划新卡  
				var that = this;
				// if(that.paytypeSettings.default_paytype) {
				// 		return DataDict["PAY_TYPE"][that.paytypeSettings.default_paytype];
				// } 
				if (that.paytypeSettings.wx_enable) return '5';
				if (that.paytypeSettings.alipay_enable) return '4';
				if (that.paytypeSettings.cash_enable) return '1';
				if (that.paytypeSettings.scan_code_enable) return '8';
				return '1';

			},
			 getCustomTitle: function(_key) {
			 			var that = this;
			 			let title = ".."
			 			that.custompaytypes.forEach((v, i) => {
							let item = v;
							if(item.key == _key) {
								title = item.title
							}
						})
						return title
			   	    }, 
			payPointsAmount: function() { //是否开卡时原卡有充值卡可以划新卡 
				var that = this;
				var calc = (parseFloat(that.integration_convert) * parseFloat(that.payPoints)).toFixed(2);

				return calc > 0 ? calc : 0;
			},
			ifHasCharge: function() { //是否开卡时原卡有充值卡可以划新卡 
				var that = this;
				if (that.memberInfo.recharge > 0) return true;
				return false;
			},
			ifHasGive: function() { //是否开卡时原卡有充值卡可以划新卡 
				var that = this;
				if (that.memberInfo.give > 0) return true;
				return false;
			},
			isEdit: function() {
				var that = this;
				return that.orderInfo.orderId > 0
			},

			disAll: function() {
				var that = this;
				return parseFloat(that.discountsAmount) + parseFloat(that.couponDiscounts) + parseFloat(that
					.payPointsAmount);

			},
			couponDiscounts: function() {
				var that = this;
				if (that.coupon) { //代金券 或者积客券
					if ((that.coupon.coupon_type == 1 || that.coupon.coupon_type == 3) || that.coupon.coupon_amount >
						0) { //代金券 或者积客券
						return parseFloat(that.coupon.coupon_amount);
					}
				}
				return 0;
			},
			realPay: function() {
				var that = this;
				var payamount = 0;
				this.payways.forEach((v, i) => {
					let payway = v;
					payamount += parseFloat(payway.payamount);
				})
				return payamount;
			},
			remainPay: function() {
				var that = this;
				var remain = (parseFloat(that.mustPay) - that.realPay - that.disAll).toFixed(2);
				if (remain < 0) remain = 0;
				return remain;
			},
			staff_name: function() {
				var that = this;
				if (that.orderStaffRecords && that.orderStaffRecords.length > 0) {
					return that.orderStaffRecords[0].staff_name;
				}
				return '';
			},
			cashClassRealPayRatio: function() { //实付比例
				var that = this;
				var payamount = that.cashamount
				if (Number(that.mustPay) > 0) {
					return parseFloat(payamount / parseFloat(that.mustPay).toFixed(2))
				}
				return 1
			},
			cashamount: function() { // 
				var that = this;
				var payamount = 0;
				this.payways.forEach((v, i) => {
					let payway = v;
					if (payway.paytype != 13 && payway.paytype != 3) {
						payamount += parseFloat(payway.payamount);
					}
				})
				return payamount
			},
			chargeamount: function() { // 
				var that = this;
				var payamount = 0;
				this.payways.forEach((v, i) => {
					let payway = v;
					if (payway.paytype == 13 || payway.paytype == 3) {
						payamount += parseFloat(payway.payamount);
					}
				})
				return payamount
			},
			coupontypeamount: function() { // 
				var that = this;
				return that.disAll
			},
			realPayRatio: function() { //实付比例
				var that = this;

				if (Number(that.orderInfo.totalPrice) > 0) {
					return parseFloat(that.realPay / parseFloat(that.orderInfo.totalPrice).toFixed(10))
				}
				return 1
			},

			charge_amount_rate: function() { //实付比例
				var that = this;

				if (Number(that.realPay) > 0) {
					return parseFloat(that.chargeamount / parseFloat(that.mustPay).toFixed(10))
				}
				return 1
			},

			cash_amount_rate: function() { //实付比例
				var that = this;

				if (Number(that.realPay) > 0) {
					return parseFloat(that.cashamount / parseFloat(that.mustPay).toFixed(10))
				}
				return 1
			},

			orderStaffRecords: function() {

				// 			if( that.orderInfo.orderStaffRecords) return  that.orderInfo.orderStaffRecords;
				var that = this;
				var staffcounts = that.cashierStaffs.length;
				if (staffcounts == 0) {
					return null
				}
				var archieves = [];
				if (that.orderType == 3) {

					let cash_amount = that.cashamount / staffcounts
					let charge_amount = that.chargeamount / staffcounts
					let coupontype_amount = that.coupontypeamount / staffcounts
					that.cashierStaffs.forEach((v, i) => {
						let cashierStaff = v;
						let staff_id = cashierStaff.id
						let archieve = {};
						archieve.staff_id = staff_id;
						archieve.staff_name = cashierStaff.trueName; {
							let extractRate = 0;
						}
						archieve.extractRate = extractRate;
						archieve.salesAmount = cash_amount;
						archieve.project_unit = extractRate * (archieve.salesAmount) / 100;
						archieve.cash_amount = cash_amount;
						archieve.charge_amount = charge_amount;
						archieve.coupontype_amount = coupontype_amount;
						archieves.push(archieve);

					})

				} else if (that.orderType == 0 || that.orderType == 4 || that.orderType == 14) {
					let cash_amount = that.cashamount / staffcounts
					let charge_amount = that.chargeamount / staffcounts
					let coupontype_amount = that.coupontypeamount / staffcounts
					that.cashierStaffs.forEach((v, i) => {
						let cashierStaff = v;
						let staff_id = cashierStaff.id
						let archieve = {};
						archieve.staff_id = staff_id;
						archieve.staff_name = cashierStaff.trueName;
						// if(that.orderInfo.combinId > 0) {
						// archieve.goods_id = that.orderInfo.combinId;
						// extractRate = baseData.getStaffBonus(that.orderInfo.combinId, staff_id, "10");
						// } else {
						let extractRate = 0;
						// }
						archieve.extractRate = extractRate;
						archieve.salesAmount = cash_amount;
						archieve.project_unit = extractRate * (archieve.salesAmount) / 100;
						archieve.cash_amount = cash_amount;
						archieve.charge_amount = charge_amount;
						archieve.coupontype_amount = coupontype_amount;
						archieves.push(archieve);

					})

				} else if (that.orderType == 1) {
					that.cashierStaffs.forEach((v, i) => {
						let cashierStaff = v;
						if (cashierStaff.goodsId) { //消费
							let staff_id = cashierStaff.id
							let goods_id = cashierStaff.goodsId
							let goodsItem = that.getCartgoodsItem(goods_id)
							let staffcount = that.getStaffcountOfGoods(goods_id)
							if (staffcount && goodsItem) {
								var isPrj = (goodsItem["goods_choice_type"] == "1");
								var consume = goodsItem["consume"];
								var goodscount = Number(goodsItem["count"]);
								var member_price = goodsItem["member_price"];
								if (typeof consume == 'undefined') {
									consume = goodsItem["price"];
								}
								let extractRate = 0;

								let cash_amount = 0
								let charge_amount = 0
								let coupontype_amount = 0

								let jiruSale = true //计入销售业绩？
								if (goodsItem.goods_type != 4) { //划卡没有销售业绩
									// 								   let sbb = baseData.getStaffBonusBean(goods_id, staff_id);
									// 								   if(sbb) {
									// 									   if(sbb.achieve_mode && sbb.achieve_mode == 1) {
									// 										  jiruSale = false
									// 									   }
									// 										   extractRate = JSON.parse(sbb.bonusDetail)[0].percentage;
									// 								   }  

									let cartGoodsTotalPrice = that.getCartGoodsTotalPrice();
									let goodsRatio = 1;
									let oneGoodstotalPrice = 0
									if (cartGoodsTotalPrice == 0) {
										oneGoodstotalPrice = 0
									} else {
										goodsRatio = Number(goodsItem["totalPrice"]) / cartGoodsTotalPrice;
										oneGoodstotalPrice = goodsRatio * (that.mustPay);
									}

									cash_amount = oneGoodstotalPrice * that.cash_amount_rate / staffcount
									cash_amount = parseFloat(cash_amount.toFixed(2));
									charge_amount = oneGoodstotalPrice * that.charge_amount_rate / staffcount
									charge_amount = parseFloat(charge_amount.toFixed(2));

									consume = Number(consume) * that.realPayRatio * goodscount / staffcount;
									consume = parseFloat(consume.toFixed(2));
								} else {
									cash_amount = 0
									consume = Number(consume) * goodscount / staffcount;
									consume = parseFloat(consume.toFixed(2));
								}


								var archieve = {
									"goods_id": goods_id,
									"goods_name": goodsItem["goods_name"],
									"staff_id": cashierStaff.id,
									"staff_name": cashierStaff.trueName,
									"goods_type": goodsItem.goods_type,
									"payway": goodsItem.payway,
									"consume": jiruSale ? (consume) : 0,
									"manual": isPrj ? Number(goodsItem["manual"]) * goodscount / staffcount
										.toFixed(2) : 0,
									"projectCount": isPrj ? goodscount / staffcount : 0,
									"extractRate": extractRate,
									"project_unit": extractRate * cash_amount / 100,
									"cash_amount": jiruSale ? cash_amount : 0,
									"charge_amount": jiruSale ? charge_amount : 0,
									"coupontype_amount": jiruSale ? coupontype_amount : 0,
									"salesAmount": jiruSale ? cash_amount : 0,
									"salesPrice": goodsItem["price"] || 0,
								}

								archieves.push(archieve);
							}
						}

					})

				}
				console.log("-----ww33======", archieves)
				return archieves;

			},

			cartGoods: function() {
				return this.projectCarts.concat(this.productCarts);
			},
		},
		methods: {
			initTime() {
				// 获取完整的年月日 时分秒，以及默认显示的数组
				let obj = dateTimePicker()
				// 精确到分的处理，将数组的秒去掉
				let lastArray = obj.dateTimeArray.pop();
				let lastTime = obj.dateTime.pop();
				let lastDate = obj.dateArray.pop()

				this.dateTimeArray = obj.dateTimeArray
				this.dateTime = obj.dateTime
				this.dateArr = obj.dateArray
			},

			changeTime(e) {
				let arr = e.detail.value
				let str = this.handleTime(arr)
				this.orderDate = str
			},
			changeAlipayTime(e) {
				this.orderDate = e.detail.value
			},
			handleTime(arr) {
				let year = this.dateArr[0][arr[0]]
				let month = this.dateArr[1][arr[1]]
				let day = this.dateArr[2][arr[2]]
				let hour = this.dateArr[3][arr[3]]
				let minu = this.dateArr[4][arr[4]]
				let str = year + '-' + month + '-' + day + ' ' + hour + ':' + minu
				return str
			},
			clearAll: function() {
				uni.removeStorageSync('orderInfo')
				uni.removeStorageSync('shoppCart')
				uni.removeStorageSync('cashierMemberCard')
				uni.removeStorageSync('__combingoodsId')
				uni.removeStorageSync('cashierStaffs')
			},

			async init() {
				var that = this;
				that.orderDate = dateFormat(null, 'Y-M-D h:m:s')
				that.projectCarts = that.orderInfo.projectCarts;
				that.productCarts = that.orderInfo.productCarts;
				that.cashierStaffs = that.orderInfo.cashierStaffs || [];
				that.mustPay = that.orderInfo.totalPrice;
				if (that.orderInfo.cardId > 0) {
					await that.loadMemberCardInfo({
						memberCardId: that.orderInfo.cardId
					}).then(res => {
						var cardData = res;
						if(cardData && cardData.integral) {
							that.memberInfo.integral = cardData.integral
						}
						if (cardData && cardData.rechargeMap) {
							that.memberInfo.recharge = cardData.rechargeMap.rechargeSurplus
							that.memberInfo.give = cardData.rechargeMap.giveSurplus
						}
					})

				}  else if(that.orderInfo.memberId > 0) {
					netKehuDetail({
						id: that.orderInfo.memberId
					}).then(res => {
						let info = res.data 
						console.log("---23-222",  info)
						this.memberInfo.integral = info.integral
					})
				} 
				
				{

					if (that.orderType == 1 && that.paytypeSettings.balance_enable && that.ifHasCharge) {
						that.payChecked = '3';
					} else if (that.orderType == 1 && that.paytypeSettings.give_enable && that.ifHasGive) {
						that.payChecked = '13';
					} else {
						that.payChecked = that.defaultPaytype;
					}

				}
			},

			loadMemberCardInfo: function(data) {

				var that = this;
				return new Promise((resolve, reject) => {
					let header = {
						'content-type': 'application/x-www-form-urlencoded'
					}
					header['Authori-vipadmin'] = uni.getStorageSync('token');
					uni.request({
						url: BASE_URL + 'customer/getMembercard',
						method: 'GET',
						data: data,
						header: header,
						success: (res) => {
							resolve(res.data.data);
						},
						fail: (err) => {
							reject('err')
						}
					});
				})
			}, 
			getCartgoodsItem: function(goods_id) {
				var that = this;
				let cartGoods = that.cartGoods;
				let item = null
				cartGoods.forEach((v, i) => {
					if (v.id == goods_id) {
						item = v
					}
				})
				return item
			},
			getCartGoodsTotalPrice: function() {
				var that = this;
				let cartGoods = that.cartGoods;
				let price = 0
				cartGoods.forEach((v, i) => {
					price += Number(v["totalPrice"])
				})
				return price
			},
			getStaffcountOfGoods: function(goods_id) {
				var that = this;
				let cashierStaffs = that.cashierStaffs;
				let cnt = 0
				cashierStaffs.forEach((v, i) => {
					if (v.goodsId == goods_id) {
						cnt++
					}
				})
				return cnt
			},
			ifShowPaytype: function(id) {
				let key = id + "_enable";
				return this.paytypeSettings[key]
			},
			//是否 发送短信
			changeAuto(e) {
				this.isSendsms = e.detail.value
			},
			saveMember: function(toSavedMember) {
				return netAddkehu(toSavedMember)
			},

			async saveOrder() {

				var that = this;
				var ok = true;
				var memberId = that.orderInfo.memberId;
				if (that.orderInfo.toSavedMember) {
					await that.saveMember(that.orderInfo.toSavedMember).then(res => {
						memberId = res.data;
					});
					if (memberId > 0) {
						that.orderInfo.memberId = memberId;
					} else {
						ok = false;
					}
				}

				if (ok) {
					that.orderInfo.orderStaffRecords = that.orderStaffRecords;
					////支付方式
					that.orderInfo.payInfos = [];
					if (that.cashierman) {
						that.orderInfo.entryUserId = that.cashierman;
					}

					that.payways.forEach((v, i) => {
						let payChecked = v;
						that.orderInfo.payInfos.push({
							paytype: payChecked.paytype,
							amount: payChecked.payamount,
							staff_id: that.cashierman
						});
					})

					if (parseFloat(that.payPointsAmount) > 0) {
						that.orderInfo.payInfos.push({
							paytype: "6",
							amount: that.payPointsAmount,
							staff_id: that.cashierman
						});
					}
					{
						that.orderInfo.orderDate = that.orderDate
						that.orderInfo.additional_no = that.additional_no;
						that.orderInfo.orderRemark = that.orderRemark;

						that.orderInfo.deducableAmount = that.realPay;
						that.orderInfo.orderArrears = that.remainPay;
						/////实付金额
						that.orderInfo.actualAmount = that.realPay;

						if (that.coupon.coupon_amount > 0) {
							that.orderInfo.cashierCouponInfo = that.coupon
						}

						that.orderInfo.totalPrice = that.mustPay; //可以改应收
					}
					var str = JSON.stringify(that.orderInfo);
					console.log("提交.that.orderInfo=" + str);


					netSaveOrder({
						data: str
					}).then(res => {
						var ofId = res.data;
						if ((that.isSendsms == '1')) {
							netSendConsumeMsg({
								ofId
							}).then(res => {
								// memberId = res.data;
							});
						}



						setTimeout(() => {
							uni.hideLoading();
							uni.showToast({
								title: '支付成功'
							});

							that.clearAll()

							setTimeout(() => {
								uni.redirectTo({
									url: './pay_success?ofId=' + ofId + '&amount=' +
										that.mustPay
								});
							}, 300);
						}, 700)
					})

				}

			},
		}
	}
</script>

<style lang="scss">
	.valueActive {
		color: #333;
	}

	.fllow_area {
		background-color: #fff;
		// padding: 0 70rpx;
		margin-bottom: 30rpx;
		padding-bottom: 30rpx;
		color: #999;

		.area_head {
			height: 100rpx;
			line-height: 100rpx;
			font-size: 32rpx;
			padding: 0 70rpx;

			text {
				color: #f00;
			}
		}

		textarea {
			width: 80%;
			height: 300rpx;
			padding: 30rpx;
			background: #f8f8f8;
			margin: 0 auto;
		}
	}

	.labellist {
		display: flex;
		justify-content: flex-start;

		.labelbox {
			display: flex;
			justify-content: flex-start;
			align-items: center;
		}
	}

	.fllow_form {
		display: flex;
		justify-content: space-between;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		border-bottom: 1rpx solid #EAEAEA;
		padding: 0 24rpx;

		.form_right {
			display: flex;
			align-items: center;
			color: #999;

			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}

			.inputtext {
				// 	height: 100rpx;
				// 	line-height: 100rpx;
				text-align: right;
			}

		}

		.theme {
			color: #5ca9fe;
		}

		text {
			color: #f00;
			margin-left: 10rpx;
		}

		.form_input {
			// input {
			// 	height: 100rpx;
			// 	line-height: 100rpx;
			// 	text-align: right;
			// }
		}

		.fllow_button {
			margin-top: 15rpx;
		}
	}

	.block {
		// width: 94%;
		// padding: 0 3% 40upx 3%;

		.title {
			width: 100%;
			font-size: 34upx;
		}

		.content {
			.orderinfo {
				width: 100%;
				border-bottom: solid 1upx #eee;

				.row {
					width: 100%;

					display: flex;

					// align-items: center;
					.nominal {
						flex-shrink: 0;
						font-size: 32upx;
						color: #7d7d7d;
					}

					.text {
						width: 70%;
						margin-left: 10upx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 32upx;
					}
				}
			}

			.pay-list {
				width: 100%;
				border-bottom: solid 1upx #eee;

				.row {
					width: 100%;
					height: 120upx;
					display: flex;
					align-items: center;

					.left {
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						align-items: center;

						image {
							width: 80upx;
							height: 80upx;
						}
					}

					.center {
						width: 100%;
						font-size: 30upx;
					}

					.right {
						width: 100upx;
						flex-shrink: 0;
						display: flex;
						justify-content: flex-end;
					}
				}
			}
		}
	}

	.pay {
		margin-top: 20upx;
		width: 100%;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;

		.btn {
			width: 70%;
			height: 80upx;
			border-radius: 80upx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			background-color: #f06c7a;
			box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.2);
		}

		.tis {
			margin-top: 10upx;
			width: 100%;
			font-size: 24upx;
			display: flex;
			justify-content: center;
			align-items: baseline;
			color: #999;

			.terms {
				color: #5a9ef7;
			}
		}
	}
</style>